<?php
/**
 * Created By PhpStorm
 * Author: patrick wu
 * Date: 2020/9/19
 * Time: 10:45
 */
namespace App\Http\Middleware;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;

class PassportCustomMiddleware
{
    /**
     * 针对后台用户更换passport 的provider
     * @param $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle($request, \Closure $next)
    {
        /**
         * 后台登录的话动态修改配置
         */
        Config::set('auth.guards.api.provider', $request->input('guard_provider', 'admins'));  // 动态配置

        return $next($request);
    }
}
